/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.object;


import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.api.Generator;
import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.helpergenerators.EndGenerator;
import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.helpergenerators.FillGenerator;
import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.helpergenerators.OpacityGenerator;
import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.helpergenerators.TimelineVarGenerator;
import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.helpergenerators.TransformGenerator;
import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.helpergenerators.VisibleGenerator;
import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.helpergenerators.WithBorderGenerator;
import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.object.interfaces.Generatable;
import pl.edu.amu.wmi.kino.visualjavafx.model.animation.transformations.Fillable;
import pl.edu.amu.wmi.kino.visualjavafx.model.animation.transformations.Movable;
import pl.edu.amu.wmi.kino.visualjavafx.model.animation.transformations.Opacitable;
import pl.edu.amu.wmi.kino.visualjavafx.model.animation.transformations.Showable;
import pl.edu.amu.wmi.kino.visualjavafx.model.animation.transformations.WithBorder;
import pl.edu.amu.wmi.kino.visualjavafx.model.objects.shapes.Elipse;
import pl.edu.amu.wmi.kino.visualjavafx.model.objects.VisualObject;

/**
 *
 * @author Admin
 */
public class EllipseGenerator  implements Generator,Generatable {

    @Override
    public boolean canGenerate(Object c) {
        if(c instanceof Elipse)
            return true;
        else return false;
    }

    @Override
    public void generate(StringBuilder sb, Object o,int recursionLevel,Object original) {
        this.generateStart(sb);
        this.generateUniqueAttributes(sb, (Elipse)o,recursionLevel);
        WithBorderGenerator.generateBorderAttributes(sb, recursionLevel);
        WithBorderGenerator.generateBorderVars(sb, (WithBorder)o, recursionLevel);

        FillGenerator.generateFillAttribute(sb, recursionLevel);
        FillGenerator.generateFillVar(sb, (Fillable)o, recursionLevel);

        OpacityGenerator.generateOpacityAttribute(sb, recursionLevel);
        OpacityGenerator.generateOpacityVar(sb, (Opacitable)o, recursionLevel);

        VisibleGenerator.generateVisibleAttribute(sb, recursionLevel);
        VisibleGenerator.generateVisibleVar(sb, (Showable)o, recursionLevel);

        TimelineVarGenerator.generateTimeline(sb, (VisualObject)o, recursionLevel,original);
        TransformGenerator.generateTransformAttributes(sb,recursionLevel);
        TransformGenerator.generateTransformVars(sb, (Movable)o,recursionLevel);

        this.generateEnd(sb);
    }
    @Override
    public void generateStart(StringBuilder sb){
        sb.append("SuperEllipse{\n");
    }
    @Override
    public void generateEnd(StringBuilder sb) {
       EndGenerator.generateEnd(sb);
    }

    @Override
    public void generateUniqueAttributes(StringBuilder sb, Object o,int recursionLevel){
        Elipse e = (Elipse)o;
        sb.append("cx:"+e.getHPos()+";\n");
        sb.append("cy:"+e.getVPos()+";\n");
        sb.append("radiusX:"+e.getSizeH()/2+";\n");
        sb.append("radiusY:"+e.getSizeV()/2+";\n");
    }

     



}
